
layui.define(['laypage', 'fly'], function(exports){

  var $ = layui.jquery;
  var layer = layui.layer;
  var util = layui.util;
  var laytpl = layui.laytpl;

  var laypage = layui.laypage;



      // 搜索结果
    $(document).ready(function () {


        //var data=lucode.parseUrl(window.location.search);

        var data={
          "text":layui.data('search').text
        };
        console.log(data);

        // 发起 post 请求
        lucode.lucodePost(lucode.serverURL+'/cmsPost/search/',data,function (res) {
            //layer.closeAll();
            // 将参数  拼装成 html 内容
            //console.log(res);
            var searchTpl = document.getElementById("searchRes");
            var html="<ul class=\"fly-case-list\" >";
            var res=res.data;
            if(res.length==0){
                return false;
            }
            for(var i=0;i<res.length;i++){
               html+="<li data-id=\"123\">\n" +
                   "      <a class=\"fly-case-img\" target=\"_blank\" href=\""+"/lucode-for-all-web/cms/index.html?postId="+res[i].id+"\">\n" +
                   "        <img src=\'"+res[i].image +"\' alt=\"随机图片\">\n" +
                   "      </a>\n" +
                   "      <h2><a href=\""+"/lucode-for-all-web/cms/index.html?postId="+res[i].id+"\" target=\"_blank\">"+res[i].title+"</a></h2>\n" +
                   "      <div class=\"fly-case-info\">\n" +
                   "        <a href=\"#\" class=\"fly-case-user\"><img src=\"http://lucode-1251927515.file.myqcloud.com/%E6%9D%83%E5%A8%81.png\"></a>\n" +
                   "        <p class=\"layui-elip\" style=\"font-size: 12px;\"><span style=\"color: #666;\">众筹目标</span></p>\n" +
                   "        <p><a class=\"fly-case-nums fly-case-active\" href=\"#\" data-type=\"showPraise\" style=\" padding:0 5px; color: #01AAED;\">"+res[i].cash+"</a>￥</p>\n" +
                   "      </div>\n" +
                   "    </li>";
            }

            html+="</ul>";
            searchTpl.innerHTML=html;




        });


    });
  exports('case', {});
});